package com.zy.project.system.online.entity.base;

import com.zy.core.common.constant.system.SysConstant;
import com.zy.core.data.jpa.support.entity.BaseEntity;
import com.zy.project.system.online.entity.OnlineSession;
import com.zy.project.system.online.entity.OnlineSession.OnlineStatus;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Type;

import javax.persistence.*;
import java.util.Date;

/**
 * 当前在线会话 sys_user_online
 *
 */
@Getter
@Setter
@ToString
@MappedSuperclass
public class BaseUserOnline extends BaseEntity {


    /** 用户会话id */
    @Id
    @Column(name = "session_id")
    private String sessionId;

    /** 部门名称 */
    @Column(name = "dept_name")
    private String deptName;

    /** 登录名称 */
    @Column(name = "login_name")
    private String loginName;

    /** 登录IP地址 */
    @Column(name = "ipaddr")
    private String ipaddr;

    /** 登录地址 */
    @Column(name = "login_location")
    private String longinLocation;

    /** 浏览器类型 */
    @Column(name = "browser")
    private String browser;

    /** 操作系统 */
    @Column(name = "os")
    private String os;

    /** session创建时间 */
    @Column(name = "start_timestamp")
    private Date startTimestamp;

    /** session最后访问时间 */
    @Column(name = "last_access_time")
    private Date lastAccessTime;

    /** 超时时间，单位为分钟 */
    @Column(name = "expire_time")
    private Long expireTime;

    /** 在线状态 */
    @Type(type = SysConstant.DB_CONVERT_NAME)
    @Column(name = "status")
    private OnlineStatus status = OnlineStatus.on_line;

    /** 备份的当前用户会话 */
    private OnlineSession session;

}
